/*
 * @Author: your name
 * @Date: 2021-03-03 19:18:25
 * @LastEditTime: 2021-06-08 21:59:23
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \game-sdk-backend\src\layouts\header\index.tsx
 */
import React from 'react';
import { Layout, Menu } from 'antd';
import style from './index.less';
import { Avatar, Dropdown } from 'antd';
import { UserOutlined, RollbackOutlined } from '@ant-design/icons';
import { globalModel } from '@/pages/globalModel';
import { history } from 'umi';
import { logout } from '@/services/user';
// import { TimLogout } from '@/components/tim/tim';

interface IProps {}

const Header = (props: IProps) => {
  const menu = (
    <Menu style={{ width: 150 }}>
      <Menu.Item
        onClick={() => {
          globalModel.TimLogout();
          logout();
          history.push('/login');
        }}
      >
        <RollbackOutlined /> 退出登录
      </Menu.Item>
    </Menu>
  );
  return (
    <Layout.Header className={style.header}>
      <div>
        <div className="logo" />
        <div className="title"></div>
      </div>
      <Dropdown overlay={menu} placement="bottomLeft">
        <div className="myInfo">
          <Avatar icon={<UserOutlined />} />
          <span className="username">{globalModel.userInfo?.username}</span>
        </div>
      </Dropdown>
    </Layout.Header>
  );
};
export default Header;
